package Day6;

/**
 * 裁判类
 */
public class Judge {
    private Player player = new Player();
    private Computer computer = new Computer();
    /**
     * 判断玩家和电脑输赢情况
     */
    public void check() {
        //积分
        int playerscore = 0;
        int comscore = 0;

        for (int i = 0; i < 7; i++) {
            System.out.println("猜拳开始请输入 1 -- 石头 2--剪刀 3--布");
            int playerInt = player.input();
            int computerInt = computer.guess();
            if (playerInt == computerInt) {
                System.out.println("平局");
                continue;
            }
            if ((playerInt == 1 && computerInt == 2) || (playerInt == 2 && computerInt == 3) || ((playerInt == 3 && computerInt == 1))) {
                System.out.println("你赢下一局!");
                player.setScore(++playerscore);
                System.out.println(computerInt);
                continue;
            } else {
                System.out.println("这局你输了!");
                computer.setScore(++comscore);
                System.out.println(computerInt);
                continue;
            }

        }
        if (player.getScore() > computer.getScore()) {
            System.out.println("你的得分是" + player.getScore() + "你赢啦!" + player.getName());
        } else {
            System.out.println("你的得分是" + player.getScore() + "你输了!" + player.getName());
        }


    }
}
